<template>
  <div class="main">
    <el-card shadow="never" class="content-wrap">
      <Header></Header>
    </el-card>
    <div class="putBox">
      <div>
        <div class="languageBox">
          <div class="radioBox">
            <div>短语音识别</div>
            <el-radio-group v-model="radio1" size="large">
              <el-radio-button label="中文普通话" />
              <el-radio-button label="英语" />
              <el-radio-button label="粤语" />
              <el-radio-button label="四川话" />
            </el-radio-group>
          </div>
          <div class="radioBox">
            <div>音频文件转写</div>
            <el-radio-group v-model="radio2" size="large">
              <el-radio-button label="中文普通话" />
              <el-radio-button label="英语" />
              <el-radio-button label="音视频字幕 (中文)" />
            </el-radio-group>
          </div>
          <div class="radioBox">
            <div>实时语音识别</div>
            <el-radio-group v-model="radio3" size="large">
              <el-radio-button label="中文普通话" />
              <el-radio-button label="英语" />
              <el-radio-button label="音视频字幕 (中文)" />
            </el-radio-group>
          </div>
        </div>
      </div>
      <div class="putVoiceBox">
        <div class="voiceList" v-show="voiceList.length !== 0">
          <div class="btnBox">
            <div class="addmore">
              <el-icon class="icon">
                  <CirclePlus />
              </el-icon>
              <div>添加更多</div>
              <input id="input1" class="addVoice" type="file" accept="image/*,audio/*,video/*" @change="inputVoice($event)">
            </div>
            <div class="addmore" style="margin-left: 20px">
              <el-icon class="icon">
                  <Refresh />
              </el-icon>
              <div>提交转换</div>
            </div>
          </div>
          <div class="voiceBox" v-for="(item,index) in voiceList" :key="index">
            <div class="Information">
              <el-icon v-if="item.type !== 'image'" class="icon">
                <VideoCamera />
              </el-icon>
              <el-icon v-else class="icon">
                <Picture />
              </el-icon>
              <div class="fileInformation">
                <div class="fileName">{{ item.name }}</div>
                <div class="fileSize">{{ item.size }}m</div>
              </div>
            </div>
              <el-icon class="icon2" @click="deleteData(index)">
                <Close />
              </el-icon>
          </div>
        </div>
        <div class="putVoice" v-show="voiceList.length === 0">
          <el-icon class="icon">
             <List />
          </el-icon>
          <div class="h3">点击添加音频、视频</div>
          <div class="h5">准确率最高97.5%·数据安全保护·支持音频和图片</div>
          <input id="input2" class="inputVoice" type="file" accept="image/*,audio/*,video/*" @change="inputVoice($event)">
        </div>
      </div>
    </div>
  </div>

</template>

<script setup lang="ts">
import { ref } from 'vue'
// import func from 'vue-temp/vue-editor-bridge'
const radio1 = ref()
const radio2 = ref()
const radio3 = ref()
const voiceList:any = ref([])
onMounted(()=>{ 
  if (sessionStorage.getItem('them') === 'fff') {
    document.documentElement.style.setProperty("--main-shallowbg-color", '#454653')
    document.documentElement.style.setProperty("--main-bg-color", '#22252a')
    document.documentElement.style.setProperty("--main-font-color", '#fff')
    document.documentElement.style.setProperty("--main-shallowfont-color", '#fff')
    document.documentElement.style.setProperty("--main-shallowfont2-color", '#fff')
    document.documentElement.style.setProperty("--el-border-color", '#454653')
    document.documentElement.style.setProperty("--main-elbtn-color", '#454653')
  } else {
    document.documentElement.style.setProperty("--main-shallowbg-color", '#f2f3f4')
    document.documentElement.style.setProperty("--main-bg-color", '#fff')
    document.documentElement.style.setProperty("--main-font-color", '#303133')
    document.documentElement.style.setProperty("--main-shallowfont-color", '#d6d7d8')
    document.documentElement.style.setProperty("--main-shallowfont2-color", 'rgba(0, 0, 0, 0.46)')
    document.documentElement.style.setProperty("--el-border-color", '#dcdfe6')
    document.documentElement.style.setProperty("--main-elbtn-color", '#409eff')
  }
})

// 选择文件提交
function inputVoice(e) {
  // console.log('$event', e.target.files)
  let size = e.target.files[0].size/1024/1024
  let fileObj = {
    name: e.target.files[0].name,
    size: size.toFixed(2),
    type: e.target.files[0].type.split('/')[0]
  }
  // console.log('fileObj',fileObj)
  voiceList.value.push(fileObj)
  (<HTMLInputElement>document.getElementById('input1')).value
  (<HTMLInputElement>document.getElementById('input2')).value
}

function deleteData(index) {
  // console.log('12',index)
  voiceList.value.splice(index,1)
}
</script>

<style lang="scss" scoped>
.main {
    min-height: 1000px;
    // padding: 20px;
    background-color: var(--main-shallowbg-color);
}
// .putBox {
//   // width: 90%;
//   // margin: 50px auto;
//   // display: flex;
//   // justify-content: space-around;
// }
.inputVoice {
  opacity: 0.0;
  width: 100%;
  height: 100%;
  top: 0px;
  left: 0px;
  position: absolute;
}
.btnBox {
  display: flex;
}
.voiceList {
  // width: 100%;
  height: 400px;
  background-color: var(--main-bg-color);
  color: var(--main-font-color);
  border-radius: 10px;
  // display: flex;
  padding: 20px;
  .addmore {
    width: 40%;
    height: 40px;
    border-radius: 10px;
    border: 1px solid;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    .addVoice {
      opacity: 0.0;
      width: 100%;
      height: 100%;
      top: 0px;
      left: 0px;
      position: absolute;
    }
  }
  .voiceBox:hover {
    box-shadow: 3px 4px 5px var(--main-shallowfont-color);
  }
  .voiceBox {
    transition-property: all;
    transition-duration: 0.6s;
    margin-top: 30px;
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--main-shallowfont-color);
    .Information {
      display: flex;
      width: 90%;
    }
    .icon {
      font-size: 35px;
    }
    .icon2 {
      font-size: 20px;
    }
    .fileInformation {
      margin: 0 20px;
      .fileName {
        font-size: 13px;
        font-weight: 600;
      }
      .fileSize {
        margin-top: 5px;
        font-size: 10px;
        color: var(--main-shallowfont2-color);
      }
    }
  }
}
.putVoice:hover {
  box-shadow: 9px 8px 12px var(--main-shallowfont-color);
}
.putVoiceBox{
  width: 90%;
  height: 300px;
  margin: 10px auto;
}
.putVoice {
  position: relative;
  transition-property: all;
  transition-duration: 0.6s;
  width: 100%;
  height: 300px;
  background-color: var(--main-bg-color);
  color: var(--main-font-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  .icon {
    font-size: 60px;
    margin-top: -60px;
    margin-bottom: 20px;
  }
  .h3 {
    font-size: 25px;
    font-weight: 600;
    margin-bottom: 10px;
  }
  .h5 {
    color: #969696;
  }
}
.languageBox {
  background-color: var(--main-shallowbg-color);
  // width: 60%;
  // height: 400px;
  padding: 10px;
  color: var(--main-font-color);
}
.radioBox {
  margin-top: 10px;
}
::v-deep .el-radio-group{
  margin: 10px;
}
::v-deep .el-radio-button__inner{
  color: var(--main-font-color);
  background-color: var(--main-bg-color);
}

@media screen and (min-width: 600px) {
  .main {
    min-height: 1000px;
    // padding: 20px;
    background-color: var(--main-shallowbg-color);
}
.putBox {
  width: 90%;
  margin: 50px auto;
  display: flex;
  justify-content: space-around;
}
.inputVoice {
  opacity: 0.0;
  width: 100%;
  height: 100%;
  top: 0px;
  left: 0px;
  position: absolute;
}
.btnBox {
  display: flex;
}
.voiceList {
  width: 100%;
  height: 400px;
  background-color: var(--main-bg-color);
  color: var(--main-font-color);
  border-radius: 10px;
  // display: flex;
  padding: 20px;
  .addmore {
    width: 20%;
    height: 40px;
    border-radius: 10px;
    border: 1px solid;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    .addVoice {
      opacity: 0.0;
      width: 100%;
      height: 100%;
      top: 0px;
      left: 0px;
      position: absolute;
    }
  }
  .voiceBox:hover {
    box-shadow: 3px 4px 5px var(--main-shallowfont-color);
  }
  .voiceBox {
    transition-property: all;
  transition-duration: 0.6s;
    margin-top: 30px;
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--main-shallowfont-color);
    .Information {
      display: flex;
      width: 90%;
    }
    .icon {
      font-size: 40px;
    }
    .icon2 {
      font-size: 20px;
    }
    .fileInformation {
      margin: 0 20px;
      .fileName {
        font-size: 17px;
        font-weight: 600;
      }
      .fileSize {
        margin-top: 5px;
        font-size: 14px;
        color: var(--main-shallowfont2-color);
      }
    }
  }
}
.putVoice:hover {
  box-shadow: 9px 8px 12px var(--main-shallowfont-color);
}
.putVoiceBox{
  width: 50%;
  height: 400px;
}
.putVoice {
  position: relative;
  transition-property: all;
  transition-duration: 0.6s;
  width: 100%;
  height: 400px;
  background-color: var(--main-bg-color);
  color: var(--main-font-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  .icon {
    font-size: 60px;
    margin-top: -60px;
    margin-bottom: 20px;
  }
  .h3 {
    font-size: 25px;
    font-weight: 600;
    margin-bottom: 10px;
  }
  .h5 {
    color: #969696;
  }
}
.languageBox {
  background-color: var(--main-shallowbg-color);
  // width: 60%;
  height: 400px;
  padding: 30px 40px 30px 30px;
  color: var(--main-font-color);
}
.radioBox {
  margin: 30px;
}
}
</style>